﻿﻿
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="<%=basePath%>">
    <!-- 下拉框 -->
    <link rel="stylesheet" href="static/ace/css/chosen.css"/>
    <!-- jsp文件头和头部 -->
    <%@ include file="../index/top.jsp" %>
    <!-- 日期框 -->
    <link rel="stylesheet" href="static/ace/css/datepicker.css"/>
    <script type="text/javascript" src="js/base.js"></script>
</head>
<body class="no-skin">

<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">
    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">

                        <!-- 检索  -->
                        <form action="account/cashApply/list.do" method="post" name="cashApplyForm" id="cashApplyForm">
                            <input type="hidden" name="classIds" id="classIds" value="${classIds}"/>
                            <table style="margin-top:5px;">
                                <tr>
                                    <td style="vertical-align:top;padding-left:2px;">
                                        <select class="chosen-select form-control" name="state" id="state"
                                                data-placeholder="状态" style="vertical-align:top;width: 120px;">
                                            <option value="00">未审核</option>
                                            <option value="01" <c:if test="${pd.state=='01'}">selected</c:if>>已通过
                                            </option>
                                            <option value="02" <c:if test="${pd.state=='02'}">selected</c:if>>未通过
                                            </option>
                                        </select>
                                    </td>
                                    <c:if test="${QX.cha == 1 }">
                                        <td style="vertical-align:top;padding-left:2px;"><a class="btn btn-light btn-xs"
                                                                                            onclick="searchs();"
                                                                                            title="检索"><i
                                                id="nav-search-icon"
                                                class="ace-icon fa fa-search bigger-110 nav-search-icon blue"></i></a>
                                        </td>
                                    </c:if>
                                </tr>
                            </table>
                            <!-- 检索  -->

                            <table id="simple-table" class="table table-striped table-bordered table-hover"
                                   style="margin-top:5px;">
                                <thead>
                                <%--标题栏（表格上方）--%>
                                <tr>
                                    <th class="center" style="width:35px;">
                                        <label class="pos-rel"><input type="checkbox" class="ace" id="zcheckbox"/><span
                                                class="lbl"></span></label>
                                    </th>
                                    <th class="center" style="width:50px;">排序</th>
                                    <th class="center">ID</th>
                                    <th class="center">用户ID</th>
                                    <th class="center">姓名</th>
                                    <th class="center">提现金额</th>
                                    <th class="center">手续费</th>
                                    <th class="center">提现方式</th>
                                    <th class="center">银行卡/支付宝</th>
                                    <th class="center">银行名称</th>
                                    <th class="center">
                                        <c:if test="${pd.state!='00'}">
                                            操作日期
                                        </c:if>
                                        <c:if test="${pd.state=='00'}">
                                            申请日期
                                        </c:if>
                                    </th>
                                    <th class="center">操作人ID</th>
                                    <th class="center">操作</th>
                                </tr>
                                </thead>

                                <tbody id="goodlist">
                                <%--数据（表格）--%>
                                <!-- 开始循环 -->
                                <c:choose>
                                    <c:when test="${not empty cashApplies}">
                                        <c:if test="${QX.cha == 1 }">
                                            <c:forEach items="${cashApplies}" var="cashApply" varStatus="vs">
                                                <tr>
                                                    <td class='center' style="width: 30px;">
                                                        <label><input type='checkbox' name='ids'
                                                                      value="${cashApply.id }"
                                                                      class="ace"/><span class="lbl"></span></label>
                                                    </td>
                                                    <td class='center' style="width: 30px;">${vs.index+1}</td>
                                                    <td class="center">${cashApply.id}</td>
                                                    <td class="center">${cashApply.user_id}</td>
                                                    <td class="center">${cashApply.real_name}</td>
                                                    <td class="center">${cashApply.price}</td>
                                                    <td class="center">${cashApply.poundage}</td>
                                                    <td class="center">
                                                        <c:if test="${cashApply.cash_mode == '01'}">
                                                            支付宝
                                                        </c:if>
                                                        <c:if test="${cashApply.cash_mode == '00'}">
                                                            银行卡
                                                        </c:if>
                                                    </td>
                                                    <td class="center">
                                                        <c:if test="${cashApply.cash_mode == '01'}">
                                                            ${cashApply.alipay_account}
                                                        </c:if>
                                                        <c:if test="${cashApply.cash_mode == '00'}">
                                                            ${cashApply.bank_card}
                                                        </c:if>
                                                    </td>
                                                    <td class="center">
                                                        <c:if test="${cashApply.cash_mode == '00'}">
                                                            ${cashApply.bank_name}
                                                        </c:if>
                                                    </td>
                                                    <td class="center">
                                                        <c:if test="${pd.state!='00'}">
                                                            ${cashApply.update_time}
                                                        </c:if>
                                                        <c:if test="${pd.state=='00'}">
                                                            ${cashApply.create_time}
                                                        </c:if>
                                                    </td>
                                                    <td class="center">${cashApply.operator_id}</td>
                                                    <td class="center">
                                                        <c:if test="${QX.edit == 1 }">
                                                            <%--<c:if test="${pd.state=='00'}">--%>
                                                            <a class="btn btn-xs btn-success" title="拒绝"
                                                               onclick="edit('${cashApply.id}');">
                                                                <i class="ace-icon fa fa-pencil-square-o bigger-120"
                                                                   title="拒绝"></i>
                                                            </a>
                                                            <%--</c:if>--%>
                                                        </c:if>
                                                    </td>
                                                </tr>

                                            </c:forEach>
                                        </c:if>
                                        <c:if test="${QX.cha == 0 }">
                                            <tr>
                                                <td colspan="15" class="center">您无权查看</td>
                                            </tr>
                                        </c:if>
                                    </c:when>
                                    <c:otherwise>
                                        <tr class="main_info">
                                            <td colspan="15" class="center">没有相关数据</td>
                                        </tr>
                                    </c:otherwise>
                                </c:choose>
                                </tbody>
                            </table>

                            <%--底部功能栏（表格下方）--%>
                            <div class="page-header position-relative">
                                <table style="width:100%;">
                                    <tr>
                                        <td style="vertical-align:top;">
                                            <c:if test="${QX.del == 1 }">
                                                <%--<c:if test="${pd.state=='00'}">--%>
                                                <a class="btn btn-mini btn-success"
                                                   onclick="allowCashout();">批量通过</a>
                                                <%--</c:if>--%>
                                            </c:if>
                                        </td>
                                        <td style="vertical-align:top;">
                                            <div class="pagination"
                                                 style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </form>

                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.page-content -->
        </div>
    </div>
    <!-- /.main-content -->

    <!-- 返回顶部 -->
    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>

</div>
<!-- /.main-container -->

<!-- basic scripts -->
<!-- 页面底部js¨ -->
<%@ include file="../index/foot.jsp" %>
<!-- 删除时确认窗口 -->
<script src="static/ace/js/bootbox.js"></script>
<!-- ace scripts -->
<script src="static/ace/js/ace/ace.js"></script>
<!-- 日期框 -->
<script src="static/ace/js/date-time/bootstrap-datepicker.js"></script>
<!-- 下拉框 -->
<script src="static/ace/js/chosen.jquery.js"></script>
<!--提示框-->
<script type="text/javascript" src="static/js/jquery.tips.js"></script>
</body>

<script type="text/javascript">
    $(top.hangge());

    //检索
    function searchs() {
        top.jzts();
        $("#cashApplyForm").submit();
    }

    function edit(id) {
//        top.jzts();
        var diag = new top.Dialog();
        diag.Drag = true;
        diag.Title = "编辑拒绝原因";
        diag.URL = '<%=basePath%>account/cashApply/editReject.do?id=' + id;
        diag.Width = 1200;
        diag.Height = 900;
        diag.CancelEvent = function () { //关闭事件
            nextPage('${page.currentPage}');
            diag.close();
        };
        diag.show();
    }

    //批量拒绝提现
    function allowCashout() {
        var state = '01';
        var chooseIds = new Array();
        var elements = document.getElementsByName('ids');
        for (var i = 0, j = 0; i < elements.length; i++) {
            if (elements[i].checked) {
                chooseIds[j++] = elements[i].value;
            }
        }

        checkCashout("<%=basePath%>", chooseIds, state);
        nextPage('${page.currentPage}');
    }

    //排序编辑
    $(function () {
        var tdObj = "";
        var oldText = "";
        var inputObj = "";
        var newText = "";
        var id = "";
        if ('${QX.edit}' == 1) {
            //给这些单元格注册鼠标点击事件
            $("#goodlist tr").each(function () {
                $(this).children('#seq').click(function () {
                    id = $(this).next().text();//获取下一个同级元素，即id
                    //找到当前鼠标单击的td
                    tdObj = $(this);
                    //保存原来的文本
                    oldText = $(this).text();
                    //创建一个文本框
                    inputObj = $("<input type='text' value='" + oldText + "'/>");
                    //去掉文本框的边框
                    inputObj.css("border-width", 0);
                    inputObj.click(function () {
                        return false;
                    });
                    //使文本框的宽度和td的宽度相同
                    inputObj.width(tdObj.width());
                    inputObj.height(tdObj.height());
                    //去掉文本框的外边距
                    inputObj.css("margin", 0);
                    inputObj.css("padding", 0);
                    inputObj.css("text-align", "center");
                    inputObj.css("font-size", "16px");
                    inputObj.css("background-color", tdObj.css("background-color"));
                    //把文本框放到td中
                    tdObj.html(inputObj);
                    //文本框失去焦点的时候变为文本
                    inputObj.blur(function () {
                        newText = $(this).val();
                        if (!isInt(newText) || newText.length > 8) {
                            alert("只能输入最多8位整数");
                            tdObj.html(oldText);
                        } else {
                            $.get("goods/updateSeq.do?id=" + id + '&seq=' + newText, function (data, status) {
                                if (data == "success") {
                                    tdObj.html(newText);
                                }
                                else {
                                    tdObj.html(oldText);
                                }
                            });
                        }

                    });
                });
            });
        }
    });

    //检查是否为正整数
    function isInt(a) {
        var reg = /^\d+$/;
        return reg.test(a);
    }

    //复选框全选控制
    var active_class = 'active';
    $('#simple-table > thead > tr > th input[type=checkbox]').eq(0).on('click', function () {
        var th_checked = this.checked;//checkbox inside "TH" table header
        $(this).closest('table').find('tbody > tr').each(function () {
            var row = this;
            if (th_checked) $(row).addClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', true);
            else $(row).removeClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', false);
        });
    });

</script>
</html>
